#include "ConvexHull.h"
#include <GL\glut.h>

void ConvexHull::AddFace(const Face& face)
{
	m_faces.push_back(face);
}

std::vector<ConvexHull::Face>* ConvexHull::GetFaces()
{
	return &m_faces;
}

void ConvexHull::Draw()
{
	std::vector<Face>::iterator it = m_faces.begin();
	std::vector<Face>::iterator end = m_faces.end();
	
	Tri tri;
	int numTris;
	int i;

	glBegin(GL_TRIANGLES);

	for( ; it != end; ++it)
	{
		numTris = it->m_tris.size();
		for(i = 0; i < numTris; i++)
		{
			tri = it->m_tris[i];			
			glVertex3f(tri.v0.x(), tri.v0.y(), tri.v0.z());
			glVertex3f(tri.v1.x(), tri.v1.y(), tri.v1.z());
			glVertex3f(tri.v2.x(), tri.v2.y(), tri.v2.z());

		}
	}


	glEnd();
}